import _ from 'lodash';
import logger from './logger';
import Promise from 'promise';
import { MessageProxy } from '../proxy';
import * as ResultMsg from '../constrants/ResultMsg';

export function sendReplyMessage(appId, masterId, authorId, topicId, replyId) {
  if (!appId || !masterId || !authorId || !topicId || !replyId) {
    logger.debug(('sendReplyMessage').red, 'type=at', `${appId}&${masterId}&${authorId}&${topicId}&${replyId}`);
    return Promise.reject(ResultMsg.PARAMS_ERROR);
  }

  return MessageProxy.create(appId, {type: 'reply', masterId, authorId, topicId, replyId});
}

export function sendAtMessage(appId, masterId, authorId, topicId, replyId) {
  if (!appId || !masterId || !authorId || !topicId || !replyId) {
    logger.debug(('sendAtMessage').red, 'type=at', `${appId}&${masterId}&${authorId}&${topicId}&${replyId}`);
    return Promise.REJECT(ResultMsg.PARAMS_ERROR);
  }

  return MessageProxy.create(appId, {type: 'at', masterId, authorId, topicId, replyId});
}
